import React, {Component} from 'react';
import {addToCart} from '../../action/cartActions';
//import store from '../../store/index';
import {connect} from 'react-redux';

class ReduxTest extends Component {
    constructor(props) {
        super(props);
    }

    componentDidMount() {
        // let {dispatch} = this.props;
        // dispatch(addToCart("你好1"));
        this.props.add();
        let {cartReducer} = this.props;
        console.log(cartReducer);
    }


    render() {
        return (
            <div onClick={this.click}>111</div>
        );
    }
}

const mapStateToProps = state => (
    {
        cartReducer: state.get('cartReducer')
    }
);

const mapDispatchToProps = (dispatch) => ({
    add() {
        dispatch(addToCart("你好"))
    }
});
export default connect(mapStateToProps, mapDispatchToProps)(ReduxTest)